from typing import Literal
from datetime import datetime
from pydantic import BaseModel, Field

KEY = Literal['code', 'aid', 'value', 'end_value', 'state', 'time', 'end_time', 'name', 'group', 'serial_number', 'is_warning']


class AlarmsRequestCount(BaseModel):
    count: int = 0


class Filter(BaseModel):
    key: KEY
    value: int | float | bool | datetime | str


class AlarmsRequest(BaseModel):
    sort_by: KEY = 'time'
    order: Literal['asc', 'desc'] = 'desc'
    start_date: datetime = datetime(year=2018, month=1, day=1)
    filters: list[Filter] = Field(default_factory=lambda: [{"key": "state", "value": "true"}])
    end_date: datetime = datetime.now()
    offset: int = 0
    count: int = 16
    language: str = 'en'
